<?php
	PhanQuyenAdmin();
	if(isset($_GET['id']) && isset($_GET['pin']))
	{
		$MaNguoiDung = trim($_GET['id']);
		$PIN        = trim($_GET['pin']);
		include_once '../classes/nguoidung_bs.php';
		include_once '../classes/nguoidungloai_bs.php';
		
		$NguoiDung = new nguoidung_bs();
		$NguoiDung->SetMaNguoiDung($MaNguoiDung);
		$DNguoiDung = $NguoiDung->LayDanhSach();
		
		if($DNguoiDung == null)
			header('Location: index.php?act=nguoidung');
		elseif(trim($DNguoiDung[0]['PIN']) == $PIN)
		{
?>
	<div class="FormCapNhat">
		
			<div class="Title">
				Thông tin chi tiết người dùng - <?php echo $DNguoiDung[0]['MaNguoiDung']; ?>
				<div style="float:right">
					<a href="index.php?act=nguoidung_capnhat&id=<?php echo $MaNguoiDung; ?>&pin=<?php echo $PIN; ?>">Cập nhật</a>
				</div>
			</div>
			
			<div class="Left">
				<table width="100%">
					<tr>
						<th colspan="2">Thông tin cá nhân</th>
					</tr>
					<tr>
						<td width="20%">Mã người dùng</td>
						<td><input name="MaHocVien" type="text" readonly="true" value="<?php echo $DNguoiDung[0]['MaNguoiDung']; ?>"/></td>
					</tr>
					<tr>
						<td>Họ tên</td>
						<td><input readonly="true" name="HoTen" style="font-weight:bold" type="text" value="<?php echo $DNguoiDung[0]['HoTen']; ?>"/></td>
					</tr>
					<tr>
						<td>Ngày sinh</td>
						<td><input readonly="true" type="text" value="<?php echo ConvertDate($DNguoiDung[0]['NgaySinh']); ?>"/></td>
					</tr>					
					<tr>
						<td>Địa chỉ</td>
						<td><input readonly="true" name="DiaChi" type="text" value="<?php echo $DNguoiDung[0]['DiaChi']; ?>"/></td>
					</tr>
					<tr>
						<td>Điện thoại</td>
						<td><input readonly="true" name="DienThoai" type="text" value="<?php echo DinhDangSDT($DNguoiDung[0]['DienThoai']); ?>"/></td>
					</tr>
					<tr>
						<td>Email</td>
						<td><input readonly="true" name="Email" type="text" value="<?php echo $DNguoiDung[0]['Email']; ?>"/></td>
					</tr>
				</table>
			</div>
			<div class="Right">
				<table width="100%">
					<tr>
						<th colspan="2">CICT</th>
					</tr>
					<tr>
						<td width="35%">Chức vụ</td>
						<td>
							<?php
								include_once '../classes/chucvu_bs.php';
								$ChucVu = new chucvu_bs();
								$ChucVu->SetMaChucVu($DNguoiDung[0]['MaChucVu']);
								$DChucVu = $ChucVu->LayDanhSach();
								$TCV = $DChucVu == null ? '-' : $DChucVu[0]['TenChucVu'];
							?>
							<input type="text" readonly="true" value="<?php echo $TCV; ?>" />
						</td>
					</tr>
					<tr>
						<td>Vai trò</td>
						<td>
							<?php
								$NguoiDungLoai = new nguoidungloai_bs();
								$NguoiDungLoai->SetMaLoaiNguoiDung($DNguoiDung[0]['MaLoaiNguoiDung']);
								$DNguoiDungLoai = $NguoiDungLoai->LayDanhSach();
								$TenLoai = ($DNguoiDungLoai == null) ? 'N/A' : $DNguoiDungLoai[0]['TenLoaiNguoiDung'];
							?>
							<input type="text" readonly="true" value="<?php echo $TenLoai; ?>"/>
						</td>
					</tr>
					
					
				</table>
				
			</div>
			
			<div class="Bottom">
				<a href="index.php?act=nguoidung" class="LinkBackToList">Danh sách người dùng</a>
			</div>
		
	</div>
<?php
		}
		else
			header('Location: index.php?act=nguoidung');
	}
	else
	{
		header('Location: index.php?act=nguoidung');
	}